package com.Jshop.search.pojo;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *  用于构建ES索引的对象
 *  定义了索引、文档、映射等相关配置
 * */
@Document(indexName = "goods", type = "_doc", shards = 1, replicas = 0)
public class Goods {
    //基本类型es会自动处理

    //spuId
    @Id
    private Long id;

    //用来进行全文检索的字段，里面包含标题、商品分类信息
    // "all": "华为 G9 青春版 华为（HUAWEI）手机 手机通讯 手机"
//    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    @Field(type = FieldType.Text)
    private String all;

    //卖点
    private String subTitle;

    //三级分类id
    private Long cid1;
    private Long cid2;
    private Long cid3;

    //品牌id
    private Long brandId;

    //创建时间
    private Date createTime;

    //价格数组，是所有sku的价格集合
    private List<Long> price;

    //sku的Json结构 用于页面展示的sku信息，不索引，不搜索。包含skuId、image、price、title字段
    @Field(type = FieldType.Keyword, index = false)
    private String skus;

    //可搜索的规格参数
    //Stirng-"价格" Object-属性值
    //对于字符串类型，还会额外存储一个字段，这个字段不会分词，用作聚合
    private Map<String,Object>  specs;



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAll() {
        return all;
    }

    public void setAll(String all) {
        this.all = all;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    public Long getCid1() {
        return cid1;
    }

    public void setCid1(Long cid1) {
        this.cid1 = cid1;
    }

    public Long getCid2() {
        return cid2;
    }

    public void setCid2(Long cid2) {
        this.cid2 = cid2;
    }

    public Long getCid3() {
        return cid3;
    }

    public void setCid3(Long cid3) {
        this.cid3 = cid3;
    }

    public Long getBrandId() {
        return brandId;
    }

    public void setBrandId(Long brandId) {
        this.brandId = brandId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<Long> getPrice() {
        return price;
    }

    public void setPrice(List<Long> price) {
        this.price = price;
    }

    public String getSkus() {
        return skus;
    }

    public void setSkus(String skus) {
        this.skus = skus;
    }

    public Map<String, Object> getSpecs() {
        return specs;
    }

    public void setSpecs(Map<String, Object> specs) {
        this.specs = specs;
    }
}
